<?php

namespace Database\Seeders;

use App\Models\AssignedCoupon;
use App\Models\AttributeGroup;
use App\Models\AttributeKey;
use App\Models\AttributeValue;
use App\Models\Category;
use App\Models\Channel;
use App\Models\Comment;
use App\Models\Coupon;
use App\Models\Bonus;
use App\Models\Product;
use App\Models\ProductImage;
use App\Models\ProductSku;
use App\Models\ProductSlide;
use App\Models\Slide;
use App\Models\User;
use App\Models\Order;
use App\Models\Balance;
use App\Models\Address;
use App\Models\OrderItem;
use App\Models\UpgradeLog;
use App\Models\OrderRefund;
use App\Models\VipPurchase;
use App\Models\OrderRefundNego;
use App\Models\Withdraw;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class DatabaseSeeder extends Seeder
{
    public function run()
    {
        $this->call($this->seeders());
    }

    protected function seeders()
    {
    	if (app()->environment('production')) {

    		auth()->logout();

		    //$this->devTruncate();

		    return [
			    AdminTablesSeeder::class,
			    AdminUserSeeder::class,
		    ];
	    } elseif (app()->environment('local')) {

    		$this->localTruncate();

		    return [
			    AdminTablesSeeder::class,
			    AdminUserSeeder::class,
			    SlideSeeder::class,
			    CategorySeeder::class,
			    ProductSeeder::class,
			    AttributeSeeder::class,
			    UserSeeder::class,
		    ];
	    } else {
    		// production
		    return [];
	    }
    }

    protected function devTruncate()
    {
	    User::truncate();
	    UpgradeLog::truncate();
	    Address::truncate();
	    OrderItem::truncate();
	    Order::truncate();
	    OrderRefundNego::truncate();
	    OrderRefund::truncate();

	    Withdraw::truncate();

	    ProductImage::truncate();
	    ProductSlide::truncate();
	    ProductSku::truncate();
	    Product::truncate();

	    AttributeValue::truncate();
	    AttributeKey::truncate();
	    AttributeGroup::truncate();

	    Comment::truncate();
    }

	protected function localTruncate()
	{
		User::truncate();
		UpgradeLog::truncate();
		Address::truncate();
		Withdraw::truncate();

		Category::truncate();

		Slide::truncate();

		AttributeGroup::truncate();
		AttributeKey::truncate();
		AttributeValue::truncate();

		Product::truncate();
		ProductSku::truncate();
		ProductSlide::truncate();
		ProductImage::truncate();

		OrderItem::truncate();
		Order::truncate();
		OrderRefundNego::truncate();
		OrderRefund::truncate();
	}
}
